package com.example.linyiquan.app.adapter;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

/**
 * Created by linyiquan on 17-4-14.
 */

public class GuideAdapter extends PagerAdapter {

    private List<View> views; //添加视图
    private Context context;  //上下文

    public GuideAdapter(List<View> views, Context context) {
        this.views = views;
        this.context = context;
    }


    /**
     * 删除视图
     *
     * @param container 视图组合
     * @param position  视图位置
     * @param object
     */
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView(views.get(position));
    }

    /**
     * 添加视图
     *
     * @param container 视图组合
     * @param position  视图位置
     * @return
     */
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(views.get(position));

        return views.get(position);
    }


    /**
     * 获取视图长度
     *
     * @return
     */
    @Override
    public int getCount() {
        return views.size();
    }


    /**
     * 获取
     *
     * @param view
     * @param object
     * @return
     */
    @Override
    public boolean isViewFromObject(View view, Object object) {
        return (view == object);
    }


}
